var $=jQuery.noConflict(),ST_WC_FRONT_SWATCH=ST_WC_FRONT_SWATCH||{},ST_WC_Chosen_attribute="",ST_WC_Show_selected_title=!1,ST_WC_Triggered_variations=[];!function(h){"use strict";ST_WC_FRONT_SWATCH.onSelect=function(){h("body").on("click","ul.st-swatch-preview span.st-custom-attribute",function(){var t,e,a;h(this).parents().is(".swiper-entry, .products-loop, .et-quick-view-wrapper, .etheme-product-grid-item, .etheme-product-list-item")||(t=h(this).closest("[data-attribute]").data("attribute"),t=h("select#"+t),e=h(this).data("value"),a=h(this).parent("li"),null==e||t.find('option[value="'+e+'"]').length?(a.hasClass("selected")?(a.removeClass("selected"),t.val(" "),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&a.css({"border-color":a.data("border-color")}),ST_WC_Show_selected_title)&&a.parents("tr").find(" > th label").attr("data-swatch-name",null)):(a.addClass("selected").siblings().removeClass("selected"),t.val(e),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&(a.removeAttr("style"),a.siblings().css({"border-color":a.data("border-color")}),a.css({"border-color":a.data("active-border-color")})),ST_WC_Show_selected_title)&&a.parents("tr").find("> th label").attr("data-swatch-name",null).attr("data-swatch-name",h(this).attr("data-name")),ST_WC_Chosen_attribute=h(this).closest("[data-attribute]").data("attribute")),t.trigger("change")):(t.val(" ").trigger("change"),a.siblings().removeClass("selected"),window.alert(sten_wc_params.i18n_no_matching_variations_text)))}),h(document).on("click",".etheme-sticky-cart .st-custom-attribute",function(){var t=h(document).find(".et_product-block .woocommerce-variation-add-to-cart");(t.hasClass("disabled")||t.hasClass("woocommerce-variation-add-to-cart-disabled"))&&h(document).find(".etheme-sticky-cart .single_add_to_cart_button").addClass("disabled")})},ST_WC_FRONT_SWATCH.singleProductPrimaryAttribute=function(){h(document).find(".variations_form.cart").on("reset_data",function(){var i=h(this);etConfig.woocommerceSettings.primary_attribute&&"et_none"!=etConfig.woocommerceSettings.primary_attribute&&ST_WC_Chosen_attribute=="pa_"+etConfig.woocommerceSettings.primary_attribute&&(ST_WC_Chosen_attribute="",setTimeout(function(){var t,e=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(i),a=e.data;e.count&&e.chosenCount&&e.count!=e.chosenCount&&(e=h.parseJSON(i.attr("data-product_variations")),e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(e,a).shift(),a=h(".woocommerce-main-image").first(),t=h(".thumbnail-item a").first(),a.find("img").attr("data-o_src")||a.find("img").attr("data-o_data-src")||(a.attr("data-o_href",a.attr("href")),a.find("img").attr({"data-o_src":a.find("img").attr("src"),"data-o_data-src":a.find("img").attr("src"),"data-o_data-large_image":a.find("img").attr("data-large_image")})),a.attr("href",e.image.full_src),a.find("img").attr({src:e.image.src,"data-src":e.image.src,"data-large_image":e.image.full_src,srcset:""}),a.parent().find("img.zoomImg").attr("src",a.find("img").attr("data-large_image")),t.attr("href",e.image.full_src).attr("data-large",e.image.full_src).attr("data-small",e.image.gallery_thumbnail_src),t.find("img").attr("src",e.image.gallery_thumbnail_src).attr("srcset",e.image.gallery_thumbnail_src))},50))})},ST_WC_FRONT_SWATCH.onSelectUpdateAttribute=function(){h("body.single-product form.variations_form").on("woocommerce_update_variation_values",function(){h(this).find("ul.st-swatch-preview").each(function(){var t=h(this).data("attribute"),t=document.getElementById(t),e=h(t).find("option"),a=h(t).find("option").eq(1),i=h(this).find("li"),s=h(t).find("option:selected"),r=[],o="";e.each(function(){""!==h(this).val()&&(r.push(h(this).val()),o=(s||a).val())}),i.each(function(){var t=this,e=h(t).find("span.st-custom-attribute").attr("data-value");h(t).removeClass("selected sten-li-disabled").addClass("sten-li-disabled"),-1!==r.indexOf(e.toString())&&(h(t).removeClass("sten-li-disabled"),e.toString()==o)&&(h(t).addClass("selected"),ST_WC_Show_selected_title)&&i.parents("tr").find(" > th label").attr("data-swatch-name",h(t).children().attr("data-name"))})})})},ST_WC_FRONT_SWATCH.onClear=function(){h("body.single-product").on("click","a.reset_variations",function(){var t=h(this).closest("form.variations_form").find("ul.st-swatch-preview li.selected");t.removeClass("selected"),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&t.css({"border-color":t.data("border-color")}),ST_WC_Show_selected_title)&&h(this).closest("form.variations_form").find("label[data-swatch-name]").attr("data-swatch-name",null)})},ST_WC_FRONT_SWATCH.productLoop={init:function(){ST_WC_FRONT_SWATCH.productLoop.itemSwatches(),ST_WC_FRONT_SWATCH.productLoop.addToCart(),ST_WC_FRONT_SWATCH.productLoop.showMoreAttr()},itemSwatches:function(){h("div.st-swatch-in-loop").each(function(){var s=h(this),t=s.find("span.st-custom-attribute:not(.sten-disabled)"),r=s.find("a.sten-reset-loop-variation, .et-delete"),o=s.closest(".product-type-variable"),n=h.parseJSON(s.attr("data-product_variations")),e=s.find("ul.has-default-attribute"),a=s.find(".et_st-select-holder");if(o.find("a.add_to_cart_button").addClass("et-st-disabled"),h(".st-swatch-btn-ready").removeClass("et-st-disabled"),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n),a.length){if(1==a.length)a.removeClass("hidden"),a.find("li.type-select").each(function(){var t=h(this).find(".st-attribute-price"),e=t.find(">span").clone();t.html(e)});else{let t=!1;a.each(function(){h(this).find("ul.has-default-attribute").length?(h(this).removeClass("hidden"),h(this).data("was-changed",!0).parent().find(".et_st-select-holder.hidden").first().removeClass("hidden"),t=!0):h(this).addClass("hidden")}),t||a.first().removeClass("hidden")}a.last().addClass("et_st-select-holder-last"),s.find(".et_st-default-holder:not(.et_st-select-holder)").length||(o.addClass("has-select-swatch-only"),s.find("a.sten-reset-loop-variation").addClass("hidden"),o.find("a.add_to_cart_button").text(sten_wc_params.add_to_cart_btn_text))}e.each(function(){var t=h(this).parent("div.st-swatch-in-loop").find("a.sten-reset-loop-variation"),e=(t.show(),ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(s)),a=e.data;e.count===e.chosenCount?(ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n),(e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,a).shift())?ST_WC_FRONT_SWATCH.productLoop.foundVariation(o,s,e):t.trigger("click")):ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n)}),t.on("click",function(){var t=h(this),e=t.parent("li"),a=e.parents(".et_st-select-holder"),i=!!a.length&&a.find(".et_st-swatch-select-title");if(t.hasClass("sten-disabled"))return!1;o.find("span.st-custom-attribute").removeClass("sten-disabled sten-enabled"),o.find("span.st-custom-attribute").parent("li").removeClass("sten-li-disabled sten-li-enabled"),e.hasClass("selected")&&sten_wc_params.is_customize_preview&&e.css({"border-color":e.data("border-color")}),e.hasClass("selected")||(e.addClass("selected").siblings().removeClass("selected"),i&&i.html(h(this).html()),a.length&&(a.data("was-changed")||a.data("was-changed",!0).parent().find(".et_st-select-holder.hidden").first().removeClass("hidden"),a.find(".et_st-swatch-select-list").addClass("hidden"),setTimeout(function(){a.find(".et_st-swatch-select-wrapper").removeClass("active"),a.find(".et_st-swatch-select-list").removeClass("hidden")},300)),ST_WC_Show_selected_title&&t.parents().is(".et-quick-view-wrapper")&&e.parents(".st-swatch-in-loop").find(".et_attribute-name[data-for="+t.parents(".et_st-default-holder").attr("data-et-holder")+"]").attr("data-swatch-name",t.attr("data-name")),sten_wc_params.is_customize_preview&&(e.removeAttr("style"),e.siblings().css({"border-color":e.data("border-color")}),e.css({"border-color":e.data("active-border-color")})),r.slideDown());var i=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(s),t=i.data;i.count===i.chosenCount?(ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n),(e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,t).shift())?ST_WC_FRONT_SWATCH.productLoop.foundVariation(o,s,e):r.trigger("click")):(etConfig.woocommerceSettings.primary_attribute&&"et_none"!=etConfig.woocommerceSettings.primary_attribute&&h(this).closest("[data-attribute]").data("attribute")=="pa_"+etConfig.woocommerceSettings.primary_attribute&&(i=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,t).shift(),ST_WC_FRONT_SWATCH.productLoop.variationsImageUpdate(o,i)),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n))}),r.on("click",function(){s.removeAttr("data-variation_id"),sten_wc_params.is_customize_preview&&(t=s.find("ul.st-swatch-preview li.selected")).css({"border-color":t.data("border-color")}),s.find(".et_st-swatch-select-title").text(sten_wc_params.select_options_btn_text),sten_wc_params.show_select_type_price&&o.removeClass("hide-product-price"),s.find("ul.st-swatch-preview li").removeClass("selected sten-li-disabled sten-li-enabled"),s.find("ul.st-swatch-preview span").removeClass("sten-disabled sten-enabled");var t=o.find("a.add_to_cart_button");let e=t;o.is(".etheme-product-grid-item, .etheme-product-list-item")&&(e=o.find(".st-swatch-popup").length&&!o.find(".st-swatch-popup .quantity-wrapper").length?o.find(".st-swatch-in-loop a.add_to_cart_button"):o.find(".etheme-product-grid-button .button-text, .etheme-product-list-button .button-text")),t.addClass("et-st-disabled").removeClass("st-swatch-btn-ready st-swatch-btn-readmore st-swatch-btn-text-changed added loading").attr("aria-label",sten_wc_params.select_options_btn_text+" "+sten_wc_params.read_more_for_btn_text+' "'+t.attr("data-product_name")+'"'),e.text(sten_wc_params.select_options_btn_text),o.find("a.added_to_cart").remove();var t=o.find("span.price").not(".price-cloned"),a=o.find(".price-cloned");a.length&&(t.html(a.html()),a.remove()),etConfig.woocommerceSettings.wishlist_for_variations&&s.trigger("reset_data"),n=h.parseJSON(s.attr("data-product_variations")),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(s,n),ST_WC_FRONT_SWATCH.productLoop.variationsImageUpdate(o,!1),ST_WC_FRONT_SWATCH.productLoop.variationsCountdownUpdate(o,!1),ST_WC_FRONT_SWATCH.productLoop.variationsLoopQty(o,!1),h(this).parents().is(".et-quick-view-wrapper")&&(h(this).parents(".et-quick-view-wrapper").find(".price:not(.price_cloned)").remove(),h(this).parents(".et-quick-view-wrapper").find(".price_cloned").removeClass("price_cloned").attr("style",null),ST_WC_Show_selected_title)&&h(this).parents(".et-quick-view-wrapper").find(".et_attribute-name[data-swatch-name]").attr("data-swatch-name",null),h(this).slideUp()})})},getChosenAttributes:function(t){var a={},i=0,s=0;return t.find("ul.st-swatch-preview").each(function(){var t="attribute_"+h(this).data("attribute"),e=h(this).find("li.selected span.st-custom-attribute").attr("data-value")||"";0<(e=e.toString()).length&&s++,i++,a[t]=e}),{count:i,chosenCount:s,data:a}},updateAttributes:function(t,l){var p,u=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(t).data;t.find("ul.st-swatch-preview").each(function(t,e){var a,i=h(e),s="attribute_"+i.data("attribute"),e=i.find("li.selected span.st-custom-attribute").data("value"),r=!0,o=h.extend(!0,{},u),n=(o[s]="",ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(l,o));for(a in n)if(void 0!==n[a]){var d,c,_=n[a].attributes;for(d in _)_.hasOwnProperty(d)&&(c=_[d],d===s)&&(n[a].variation_is_active,n[a].is_in_stock)&&(c?i.find('span.st-custom-attribute[data-value="'+c+'"]'):i.find("span.st-custom-attribute")).addClass("sten-enabled")}p=i.find("span.st-custom-attribute.sten-enabled").length,!e||0!==p&&0!==i.find('span.st-custom-attribute.sten-enabled[data-value="'+ST_WC_FRONT_SWATCH.productLoop.addSlashes(e)+'"]').length||(r=!1),i.find("span.st-custom-attribute:not(.sten-enabled)").addClass("sten-disabled"),i.find("span.st-custom-attribute:not(.sten-enabled)").parent("li").addClass("sten-li-disabled"),e&&r||i.find("li.selected").removeClass("selected")})},findMatchingVariations:function(t,e){for(var a=[],i=0;i=e||""==e)?h(this).attr("disabled",null):s.val(s.find("option:not([disabled]):first").val())})}else s.attr("min",i.min_qty),s.attr("max",i.max_qty),i.max_qty